<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

/** Encyclopédie **/
Route::get("encyclopedie/{permalink}.html",array('as' => 'bg-article', 'uses' => "EncyclopediaController@index"));

/** AuthN **/
Route::post("authentification.html",array('as' => 'login', 'uses' => 'LoginController@postIndex'));
Route::get("authentification.html",array('as' => 'logout', 'uses' => 'LoginController@getIndex'));

/** Lost password **/
Route::get("inscription/mot-de-passe-oublie.html",array('as' => 'lost-password', 'uses' => 'LoginController@getLostPassword'));
Route::post("inscription/mot-de-passe-oublie.html",array('as' => 'post-lost-password', 'uses' => 'LoginController@postLostPassword'));
Route::get("inscription/recuperation-mot-de-passe.html",array('as' => 'get-password', 'uses' => 'LoginController@getPassword'));

/** Compte **/
Route::post("inscription/index.html",array('as' => 'register', 'uses' => 'AccountController@postIndex'));
Route::get("inscription/index.html",array('as' => 'inscription', 'uses' => 'AccountController@getIndex'));
Route::get("inscription/validation-compte-{account}.html",array('as' => 'valide-account', 'uses' => 'AccountController@getValidation'));

/** ShoutBox **/
Route::post("shoutbox.html",array('as' => 'shoutIt', 'uses' => 'AsyncController@shoutIt'));
Route::get("shoutbox.html",array('as' => 'shoutList', 'uses' => 'AsyncController@shoutList'));
Route::get("shoutbox-archive.html",array('as' => 'shoutbox', 'uses' => 'ShoutboxController@getShout'));

/** Commentaires **/
Route::post("news-comments.html",array('as' => 'post-comment', 'uses' => 'AsyncController@postComment'));
Route::get("news-comments.html",array('as' => 'comment-list', 'uses' => 'AsyncController@getComments'));

/** Mes personnages **/
Route::get("mes-personnages/index.html",array('as' => 'my-char', 'uses' => 'AccountController@getChar'));
Route::post("mes-personnages/index.html",array('as' => 'add-char', 'uses' => 'AccountController@postChar'));

/** Calendrier **/
Route::get("instances/calendrier.html",array('as' => 'calendar', 'uses' => 'CalendarController@index'));

/** Calendrier **/
Route::get("instances/event-feed.json",array('as' => 'eventfeed', 'uses' => 'EventController@eventFeed'));
Route::get("instances/event-members-{id}-feed.json",array('as' => 'eventmember', 'uses' => 'EventController@eventMember'))->where('id','[0-9]+');;

/** News **/
Route::get("news/{year}/{month}/{day}/{permlink}.html",array('as' => 'news', 'uses' => 'NewsController@getIndex'))
	->where(array(
			'year' => '[0-9]{4}',
			'month' => '[0-9]{2}',
			'day' => '[0-9]{2}'
		));

/** Home Page **/
Route::any('{home}', array('as' => 'index', 'uses' => 'HomeController@getIndex'))->where('home','$|index.html');

/** Admin News **/
Route::get("totally-not-an-admin-page/news.html", array('as' => 'admin-news', 'uses' => 'Admin_NewsController@getNews'));
Route::get("totally-not-an-admin-page/add-news.html", array('as' => 'admin-add-news', 'uses' => 'Admin_NewsController@getAddNews'));
Route::post("totally-not-an-admin-page/add-news.html", array('as' => 'admin-post-add-news', 'uses' => 'Admin_NewsController@postAddNews'));
Route::get("totally-not-an-admin-page/edit-news-{id}.html", array('as' => 'admin-edit-news', 'uses' => 'Admin_NewsController@getEditNews'))->where('id','[0-9]+');
Route::post("totally-not-an-admin-page/edit-news-{id}.html", array('as' => 'admin-post-edit-news', 'uses' => 'Admin_NewsController@postEditNews'))->where('id','[0-9]+');
Route::get("totally-not-an-admin-page/delete-news-{id}.html", array('as' => 'admin-delete-news', 'uses' => 'Admin_NewsController@getDeleteNews'))->where('id','[0-9]+');
Route::post("totally-not-an-admin-page/delete-news-{id}.html", array('as' => 'admin-post-delete-news', 'uses' => 'Admin_NewsController@postDeleteNews'))->where('id','[0-9]+');

/** Admin Users **/
Route::get("totally-not-an-admin-page/users.html", array('as' => 'admin-users', 'uses' => 'Admin_UsersController@getUsers'));
Route::get("totally-not-an-admin-page/edit-users-{id}.html", array('as' => 'admin-edit-users', 'uses' => 'Admin_UsersController@getEditusers'))->where('id','[0-9]+');
Route::post("totally-not-an-admin-page/edit-users-{id}.html", array('as' => 'admin-post-edit-users', 'uses' => 'Admin_UsersController@postEditusers'))->where('id','[0-9]+');
Route::get("totally-not-an-admin-page/delete-users-{id}.html", array('as' => 'admin-delete-users', 'uses' => 'Admin_UsersController@getDeleteusers'))->where('id','[0-9]+');
Route::post("totally-not-an-admin-page/delete-users-{id}.html", array('as' => 'admin-post-delete-users', 'uses' => 'Admin_UsersController@postDeleteusers'))->where('id','[0-9]+');

/** Admin Users Async **/
Route::post("totally-not-an-admin-page/search-users.html", array('as' => 'users-search', 'uses' => 'Admin_UsersController@asyncSearchUsers'));

/** Admin Raid **/
Route::get("totally-not-an-admin-page/raids.html", array('as' => 'admin-raids', 'uses' => 'Admin_RaidController@getRaids'));
Route::get("totally-not-an-admin-page/add-raid.html", array('as' => 'admin-add-raid', 'uses' => 'Admin_RaidController@addRaid'));
Route::post("totally-not-an-admin-page/add-raid.html", array('as' => 'admin-post-add-raid', 'uses' => 'Admin_RaidController@postAddRaid'));

/** Admin BG **/
Route::get("totally-not-an-admin-page/article.html", array('as' => 'admin-articles', 'uses' => 'Admin_ArticleController@getArticles'));
Route::get("totally-not-an-admin-page/add-article.html", array('as' => 'admin-add-article', 'uses' => 'Admin_ArticleController@newArticle'));
Route::post("totally-not-an-admin-page/add-article.html", array('as' => 'admin-post-add-article', 'uses' => 'Admin_ArticleController@postAddArticle'));
Route::get("totally-not-an-admin-page/edit-article-{id}.html", array('as' => 'admin-get-edit-article', 'uses' => 'Admin_ArticleController@editArticle'));
Route::post("totally-not-an-admin-page/edit-article-{id}.html", array('as' => 'admin-post-edit-article', 'uses' => 'Admin_ArticleController@postEditArticle'));
Route::get("totally-not-an-admin-page/delete-article-{id}.html", array('as' => 'admin-delete-article', 'uses' => 'Admin_ArticleController@deleteArticle'));

/** Admin Documents **/
Route::get("totally-not-an-admin-page/documents-{id}.html", array('as' => 'admin-docs', 'uses' => 'Admin_DocumentController@getIndex'))->where('id','[0-9]+|root');
Route::get("totally-not-an-admin-page/add-documents-{id}.html", array('as' => 'admin-add-docs', 'uses' => 'Admin_DocumentController@getAddDocument'))->where('id','[0-9]+|root');
Route::post("totally-not-an-admin-page/add-documents-{id}.html", array('as' => 'admin-post-add-docs', 'uses' => 'Admin_DocumentController@postAddDocument'))->where('id','[0-9]+|root');
Route::get("totally-not-an-admin-page/add-folder-{id}.html", array('as' => 'admin-add-folder', 'uses' => 'Admin_DocumentController@getAddFolder'))->where('id','[0-9]+|root');
Route::post("totally-not-an-admin-page/add-folder-{id}.html", array('as' => 'admin-post-add-folder', 'uses' => 'Admin_DocumentController@postAddFolder'))->where('id','[0-9]+|root');
Route::get("totally-not-an-admin-page/delete-file-{id}.html", array('as' => 'admin-delete-file', 'uses' => 'Admin_DocumentController@getDeleteFile'))->where('id','[0-9]+');

/** Admin Async **/
Route::post("totally-not-an-admin-page/search-characters.html", array('as' => 'char-search', 'uses' => 'Admin_RaidController@asyncSearchCharacter'));

/** Admin Home **/
Route::get("totally-not-an-admin-page/index.html", array('as' => 'admin-index', 'uses' => 'Admin_AdminController@getIndex'));

Route::filter('admin', function()
{
    if(Auth::guest() || Auth::user()->status != "2") {
		return Redirect::route("index","index.html");
	}
});

Route::when('totally-not-an-admin-page/*', 'admin');

Route::filter('compte', function()
{
    if(Auth::guest()) {
		return Redirect::route("index","index.html");
	}
});

Route::when('compte/*', 'compte');

Route::filter('register', function()
{
    if(Auth::check()) {
		return Redirect::route("index","index.html");
	}
});

Route::when('inscription/*', 'register');
